﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Beetle.Sl.EditorControl.Core;
using System.IO;

namespace Beetle.Sl.EditorControl.Commands
{
    [CommandAttribute]
    public class SaveAsLocalFileDocCommand : DocCommand
    {
        public override string CommandText
        {
            get
            {
                return "SaveAsLocalFile";
            }
        }

        public override void Excute(object parameter)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.Filter = "Rich xaml Files | *.rich";
            saveFileDialog.DefaultExt = "rich";
            if (saveFileDialog.ShowDialog() == true)
            {
                Stream stream = saveFileDialog.OpenFile();
                byte[] bytes = this.Editor.GetZipBytes();
                stream.Write(bytes, 0, bytes.Length);
                stream.Close();
            }
        }
    }
}
